﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameRoly : MonoBehaviour {

    public RolyType rolyType;

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Cube"))
        {
            other.GetComponent<MeshRenderer>().material.color = AstarUtility.Instance.colors[(int)rolyType];
            

            CubeGrid cubeGrid = other.GetComponent<CubeGrid>();
            cubeGrid.gridType = rolyType;

            if (cubeGrid.gridType == RolyType.Start)
            {
                AstarUtility.Instance.startPoint = new Vector2(cubeGrid.x, cubeGrid.y);
            }
            else if (cubeGrid.gridType == RolyType.End)
            {
                AstarUtility.Instance.endPoint = new Vector2(cubeGrid.x, cubeGrid.y);
            }
        }
    }
}
